package cn.zane.designPattern.createPatterns.abstractFactoryPatterns.design.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @Author: zane
 * @Date: 2024/12/29
 * @Description:
 */
public class ClassLoaderUtils {

    /**
     * 判断args的参数的具体类型
     */
    public static Class<?>[] getClazzByArgs(Object[] args) {
        Class<?>[] parameterTypes = new Class[args.length];
        for (int i = 0; i < args.length; i++) {
            if (args[i] instanceof ArrayList) {
                parameterTypes[i] = List.class;
                continue;
            }
            if (args[i] instanceof LinkedList) {
                parameterTypes[i] = LinkedList.class;
                continue;
            }
            if (args[i] instanceof HashMap) {
                parameterTypes[i] = HashMap.class;
                continue;
            }
            if (args[i] instanceof Long) {
                parameterTypes[i] = Long.class;
                continue;
            }
            if (args[i] instanceof Double) {
                parameterTypes[i] = Double.class;
                continue;
            }
            if (args[i] instanceof TimeUnit) {
                parameterTypes[i] = TimeUnit.class;
                continue;
            }
            parameterTypes[i] = args[i].getClass();
        }
        return parameterTypes;
    }
}
